#ifndef LOGFILE_H_
#define LOGFILE_H_

#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <fcntl.h>
#include <time.h>
#include <sys/stat.h>
#include "Constants.h"

using namespace std;

class LogFile {

private:
	struct flock fl;
	int fd;
	string name;
	bool isDestroyed;

	string getDefaultLogFile();
	int openLogFile();

	int lock();
	int unlock();

    string getLogMessage(string message);

public:
	LogFile();
	LogFile(string fileName);
	virtual ~LogFile();

	int log(string message);

	void destroy();
};

#endif /* LOGFILE_H_ */
